import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import formatTime from '@/utils/time.js'
import 'amfe-flexible'
import { Button, NavBar, Row, Col, Image, Badge, Form, Search, Field, Tabbar, TabbarItem, Icon, Tab, Tabs, List, Cell, PullRefresh, ActionSheet, Dialog, Popup, Divider, Tag, CellGroup, DatetimePicker } from 'vant'

Vue.prototype.formatTime = formatTime

Vue.use(DatetimePicker)
Vue.use(CellGroup)
Vue.use(Image)
Vue.use(Tag)
Vue.use(Popup)
Vue.use(Divider)
Vue.use(ActionSheet)
Vue.use(NavBar)
Vue.use(Form)
Vue.use(Icon)
Vue.use(Field)
Vue.use(Button)
Vue.use(Tabbar)
Vue.use(TabbarItem)
Vue.use(Tab)
Vue.use(Tabs)
Vue.use(List)
Vue.use(Search)
Vue.use(Cell)
Vue.use(PullRefresh)
Vue.use(Dialog)
Vue.use(Row)
Vue.use(Col)
Vue.use(Badge)

// 自动获取焦点
Vue.directive('focus', {
  inserted (el) {
    if (el.tagName === 'TEXTAREA') {
      el.focus()
      return
    }
    const txt = el.querySelector('textarea')
    if (txt) {
      txt.focus()
      return
    }
    const inp = el.querySelector('input')
    if (inp) {
      inp.focus()
    }
  }
})
Vue.config.productionTip = false
new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
